using ASP;
using HoWave.Common;
using HoWave.Data.Bll;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Member_JXC_StockOrderSaleSelect : Member, IRequiresSessionState
{
	private string linkHead = "";
	private string showProType = "";
	private string proTypeWhere = "";
	protected ScriptManager sm;
	protected Literal ltrProType;
	protected TextBox ProductList;
	protected HiddenField hfProductList;
	protected GridView GridView1;
	protected Literal ltrPagePanel;
	protected UpdatePanel upGv;
	protected HtmlForm productform;
	public new string ShowProType
	{
		get
		{
			if (base.Request.QueryString["showProType"] != null)
			{
				this.showProType = base.Request.QueryString["showProType"].ToString();
			}
			return this.showProType;
		}
	}
	public string ProTypeWhere
	{
		get
		{
			if (!string.IsNullOrEmpty(this.ShowProType))
			{
				string text = this.ShowProType;
				if (text != null)
				{
					if (text == "1")
					{
						this.ltrProType.Text = Language.Get("Shop/Product/ProductType1") + "——";
						goto IL_14A;
					}
					if (text == "2")
					{
						this.ltrProType.Text = Language.Get("Shop/Product/ProductType2") + "——";
						goto IL_14A;
					}
					if (text == "3")
					{
						this.ltrProType.Text = Language.Get("Shop/Product/ProductType3") + "——";
						goto IL_14A;
					}
					if (text == "4")
					{
						this.ltrProType.Text = Language.Get("Shop/Product/ProductType4") + "——";
						goto IL_14A;
					}
					if (text == "5")
					{
						this.ltrProType.Text = Language.Get("Shop/Product/ProductType5") + "——";
						this.proTypeWhere = " and O.TradeType=5 ";
						goto IL_14A;
					}
				}
				this.proTypeWhere = " and O.TradeType<>5 ";
				IL_14A:;
			}
			else
			{
				this.proTypeWhere = " and O.TradeType<>5 ";
			}
			return this.proTypeWhere;
		}
	}
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			this.hfProductList.Value = Fetch.Get("DefaultValue");
			if (!string.IsNullOrEmpty(this.hfProductList.Value))
			{
				string sql = "select OrderFormID,OrderFormNum from HLShop_Order where OrderFormID in (" + this.hfProductList.Value + ")";
				DataTable dataTable = this.conn.GetDataTable(sql);
				string text = "";
				string text2 = "";
				string[] array = this.hfProductList.Value.Split(new char[]
				{
					','
				});
				for (int i = 0; i < dataTable.Rows.Count; i++)
				{
					text = text + dataTable.Rows[i]["OrderFormNum"].ToString() + ",";
					text2 = text2 + dataTable.Rows[i]["OrderFormID"].ToString() + ",";
				}
				if (text != "")
				{
					text = text.Substring(0, text.Length - 1);
					text2 = text2.Substring(0, text2.Length - 1);
				}
				this.ProductList.Text = text;
				this.hfProductList.Value = text2;
			}
			this.BindList();
		}
	}
	protected void BindList()
	{
		string text = this.QuestString();
		Shop_Order shop_Order = new Shop_Order(this.conn);
		CurrPageLinks currPageLinks = new CurrPageLinks();
		int num = this.GridView1.PageIndex;
		if (Fetch.Get("pageindex") != null)
		{
			num = Convert.ToInt32(Fetch.GetID("pageindex").ToString());
			if (num == 0)
			{
				num = 1;
			}
		}
		string text2 = string.Concat(new object[]
		{
			" From [HLShop_Order] O Inner Join [HLShop_OrderItem] I On I.OrderFormID=O.OrderFormID Where O.SalerID=",
			base.user.UserID,
			" and o.Status<>0 and (o.OrderFormID not in (select OrderID from HLJXC_StockInfoOrder where StockOrderType<>'xsgjd' group by OrderID)) and I.ID in(select max(ID) from HLShop_OrderItem Group by OrderFormID) ",
			text,
			" "
		});
		string str = "Order By O.OrderFormID Desc";
		int pageSize = this.GridView1.PageSize;
		ClientByPage clientByPage = new ClientByPage();
		int listCount = clientByPage.GetListCount("select count(*)" + text2);
		string url = "StockOrderSaleSelect.aspx?1=1" + this.linkHead + "&pageindex";
		int startIndex = (num - 1) * pageSize + 1;
		int endIndex = num * pageSize;
		string str2 = "ROW_NUMBER() OVER (" + str + ") as row,O.OrderFormID,o.OrderFormNum,InputTime,O.BuyerName,O.TradeType,MoneyTotal,MoneyReceipt,ProductID,ProductName ";
		string strSQL = "select " + str2 + text2;
		DataTable listPage = clientByPage.GetListPage(strSQL, "row", startIndex, endIndex);
		this.GridView1.DataSource = listPage;
		this.GridView1.DataBind();
		if (listPage.Rows.Count > 0)
		{
			this.ltrPagePanel.Text = currPageLinks.CurrPageLink(num, pageSize, listCount, "条记录&nbsp;每页" + pageSize + "条记录&nbsp;", url);
		}
	}
	protected string QuestString()
	{
		return "and ((O.TradeType=2 and DateDiff(s,UpdateTime,getdate())>=0 and (AuctionEndPrice in(select max(AuctionEndPrice) from HLShop_Order as a,HLShop_OrderItem as b where a.OrderFormID=b.OrderFormID Group by b.ProductID))) or (O.TradeType=3 and O.Teameffect=1) or (O.TradeType<>2 and O.TradeType<>3)) " + this.ProTypeWhere;
	}
	protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
	{
		this.GridView1.PageIndex = e.NewPageIndex;
		this.BindList();
	}
}
